package fr.bda.cloud;

import java.rmi.RemoteException;

/**
 * This class represent an error in the cloud
 * 
 * @author BARET
 * @since 21/10/2012
 */
public class CloudException extends RemoteException {

	/** The default serial */
	private static final long serialVersionUID = 1L;

	// ###################################################
	/** Impossible to add StorageUnit without a Name */
	public static final String ERR_ADD_STORAGE_UNIT_NULL_NAME = "ERR_STORAGE_UNIT_NULL_NAME";
	/** Impossible to add StorageUnit without a IP */
	public static final String ERR_ADD_STORAGE_UNIT_NULL_IP = "ERR_STORAGE_UNIT_NULL_IP";
	/** Impossible to add StorageUnit, name [%s] already exist */
	public static final String ERR_ADD_STORAGE_UNIT_NAME_ALREADY_EXIST = "ERR_STORAGE_UNIT_NAME_ALREADY_EXIST";
	// ###################################################

	/** The error code */
	private String errorCode;

	/** The error argument to use to build the error message */
	private Object[] errorArgs;

	/**
	 * To create a CloudException
	 * 
	 * @param errorCode
	 *            The error code
	 * @param errorArgs
	 *            The error argument to build the error message
	 * @return The CloudException initialize with the errorCode and the
	 *         errorArgs
	 */
	public static CloudException newCloudException(String errorCode, Object... errorArgs) {
		CloudException ce = new CloudException();
		ce.errorCode = errorCode;
		ce.errorArgs = errorArgs;
		return ce;
	}

	public String getErrorCode() {
		return errorCode;
	}

	public void setErrorCode(String errorCode) {
		this.errorCode = errorCode;
	}

	public Object[] getErrorArgs() {
		return errorArgs;
	}

	public void setErrorArgs(Object[] errorArgs) {
		this.errorArgs = errorArgs;
	}

}
